package net.grzechocinski.pages;

import net.grzechocinski.wordcounter.KMP.WordObject;
import net.grzechocinski.wordcounter.core.WordCounter;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
import org.apache.wicket.model.PropertyModel;

import java.util.ArrayList;
import java.util.List;

public class WordCounterStartPage extends WebPage {

	private static final long serialVersionUID = 1L;

	private String textToAnalyze = "[Type text to analyze here...";

	public WordCounterStartPage() {

		PropertyModel<String> messageModel = new PropertyModel<String>(this, "textToAnalyze");

		// Add a form to change the message. We don't need to do anything
		// else with this form as the shared model is automatically updated
		// on form submits
		Form<?> form = new MyForm("analyzeForm");
		form.add(new Label("inputLabel", "Text to analyze"));
		form.add(new TextArea("inputTextArea", messageModel));
		add(form);

		// Add the simplest type of label
		//add(new Label("result", wordsModel));
	}

	public String getTextToAnalyze() {
		return textToAnalyze;
	}

	public void setTextToAnalyze(String textToAnalyze) {
		this.textToAnalyze = textToAnalyze;
	}

	class MyForm extends Form {

		public MyForm(String id) {
			super(id);
		}

		@Override
		protected void onSubmit() {
			PageParameters params = new PageParameters();
			params.add("textToAnalyze", textToAnalyze);
			setResponsePage(ResultsPage.class, params);
		}
	}
}
